package spring;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = true)
public class ProxyEnabledConfiguration {

    @Bean
    public MyBean myBean() {
        return new MyBean();
    }

    @Bean
    public AnotherBean anotherBean() {
        //开启代理，实例Bean会被缓存，直接返回已存在的Bean
        return new AnotherBean(myBean());
    }

}
